/*
Copyright (C) 2012 John Tsiombikas <nuclear@member.fsf.org>,
                   Ioannis Makris <imak@imak.gr>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/* GLUT API front-end for libglory */
#ifndef GLORY_GLUT_H_
#define GLORY_GLUT_H_

/* glutGet options */
enum {
	GLUT_WINDOW_X,
	GLUT_WINDOW_Y,
	GLUT_WINDOW_WIDTH,
	GLUT_WINDOW_HEIGHT,
	GLUT_WINDOW_BUFFER_SIZE,
	GLUT_WINDOW_STENCIL_SIZE,
	GLUT_WINDOW_DEPTH_SIZE,
	GLUT_WINDOW_RED_SIZE,
	GLUT_WINDOW_GREEN_SIZE,
	GLUT_WINDOW_BLUE_SIZE,
	GLUT_WINDOW_ALPHA_SIZE,
	GLUT_WINDOW_ACCUM_RED_SIZE,
	GLUT_WINDOW_ACCUM_GREEN_SIZE,
	GLUT_WINDOW_ACCUM_BLUE_SIZE,
	GLUT_WINDOW_ACCUM_ALPHA_SIZE,
	GLUT_WINDOW_DOUBLEBUFFER,
	GLUT_WINDOW_RGBA,
	GLUT_WINDOW_PARENT,
	GLUT_WINDOW_NUM_CHILDREN,
	GLUT_WINDOW_COLORMAP_SIZE,
	GLUT_WINDOW_NUM_SAMPLES,
	GLUT_WINDOW_STEREO,
	GLUT_WINDOW_CURSOR,

	GLUT_SCREEN_WIDTH,
	GLUT_SCREEN_HEIGHT,
	GLUT_SCREEN_WIDTH_MM,
	GLUT_SCREEN_HEIGHT_MM,

	GLUT_MENU_NUM_ITEMS,
	GLUT_DISPLAY_MODE_POSSIBLE,

	GLUT_INIT_DISPLAY_MODE,
	GLUT_INIT_WINDOW_X,
	GLUT_INIT_WINDOW_Y,
	GLUT_INIT_WINDOW_WIDTH,
	GLUT_INIT_WINDOW_HEIGHT,

	GLUT_ELAPSED_TIME
};

/* glutLayerGet options */
enum {
	GLUT_OVERLAY_POSSIBLE,
	GLUT_LAYER_IN_USE,
	GLUT_HAS_OVERLAY,
	GLUT_TRANSPARENT_INDEX,
	GLUT_NORMAL_DAMAGED,
	GLUT_OVERLAY_DAMAGED
};

/* glutGetModifiers mask bits */
#define GLUT_ACTIVE_SHIFT	1
#define GLUT_ACTIVE_CTRL	2
#define GLUT_ACTIVE_ALT		4

enum {
	/* bitmap fonts */
	GLUT_BITMAP_8_BY_13,
	GLUT_BITMAP_9_BY_15,
	GLUT_BITMAP_TIMES_ROMAN_10,
	GLUT_BITMAP_TIMES_ROMAN_24,
	GLUT_BITMAP_HELVETICA_10,
	GLUT_BITMAP_HELVETICA_12,
	GLUT_BITMAP_HELVETICA_18,

	/* stroke (vector) fonts */
	GLUT_STROKE_ROMAN,
	GLUT_STROKE_MONO_ROMAN
};


#ifdef __cplusplus
extern "C" {
#endif

/* initialization */
void glutInit(int argc, char **argv);
void glutInitDisplayMode(unsigned int mode);
void glutInitWindowSize(int xsz, int ysz);
void glutInitWindowPosition(int x, int y);

/* window management */
int glutCreateWindow(const char *title);
int glutCreateSubWindow(int parent, int x, int y, int xsz, int ysz);
void glutDestroyWindow(int win);
void glutSetWindow(int win);
int glutGetWindow(void);

void glutPostRedisplay(void);
void glutSwapBuffers(void);

void glutPositionWindow(int x, int y);
void glutReshapeWindow(int xsz, int ysz);

void glutFullScreen(void);

void glutPushWindow(void);
void glutPopWindow(void);
void glutShowWindow(void);
void glutHideWindow(void);
void glutIconifyWindow(void);

/* callback registration */
void glutDisplayFunc(void (*func)(void));
void glutOverlayDisplayFunc(void (*func)(void));
void glutIdleFunc(void (*func)(void));
void glutReshapeFunc(void (*func)(int, int));
void glutKeyboardFunc(void (*func)(unsigned char, int, int));
void glutKeyboardUpFunc(void (*func)(unsigned char, int, int));
void glutSpecialFunc(void (*func)(int, int, int));
void glutSpecialUpFunc(void (*func)(int, int, int));
void glutMouseFunc(void (*func)(int, int, int, int));
void glutMotionFunc(void (*func)(int, int));
void glutPassiveFunc(void (*func)(int, int));
void glutSpaceballMotionFunc(void (*func)(int, int, int));
void glutSpaceballRotateFunc(void (*func)(int, int, int));
void glutSpaceballButtonFunc(void (*func)(int, int));
void glutButtonBoxFunc(void (*func)(int, int));
void glutDialsFunc(void (*func)(int, int));
void glutTabletMotionFunc(void (*func)(int, int));
void glutTabletButtonFunc(void (*func)(int, int, int, int));
void glutMenuStatusFunc(void (*func)(int, int, int));
void glutMenuStateFunc(void (*func)(int));
void glutVisibilityFunc(void (*func)(int));
void glutEntryFunc(void (*func)(int));
void glutTimerFunc(unsigned int msecs, void (*func)(int));

/* event processing */
void glutMainLoop(void);

/* overlays */
void glutEstablishOverlay(void);
void glutUseLayer(int layer);
void glutRemoveOverlay(void);
void glutPostOverlayRedisplay(void);
void glutShowOverlay(void);
void glutHideOverlay(void);

/* menus */
int glutCreateMenu(void (*func)(int));
void glutSetMenu(int menu);
int glutGetMenu(void);
void glutDestroyMenu(int menu);
void glutAddMenuEntry(char *name, int value);
void glutAddSubMenu(char *name, int menu);
void glutChangeToMenuEntry(int entry, char *name, int value);
void glutChangeToSubMenu(int entry, char *name, int menu);
void glutRemoveMenuItem(int entry);
void glutAttachMenu(int bn);
void glutDetachMenu(int bn);

/* colormap (unimplemented) */
void glutSetColor(int cell, float red, float green, float blue);
float glutGetColor(int cell, int component);
void glutCopyColormap(int win);

/* state retrieval */
int glutGet(int state);
int glutLayerGet(int info);
int glutGetModifiers(void);
int glutExtensionSupported(char *ext);

/* font rendering */
void glutBitmapCharacter(void *font, int c);
int glutBitmapWidth(void *font, int c);
void glutStrokeCharacter(void *font, int c);
void glutStrokeWidth(void *font, int c);

/* geometry rendering */
void glutSolidSphere(double rad, int slices, int stacks);
void glutWireSphere(double rad, int slices, int stacks);

void glutSolidCube(double size);
void glutWireCube(double size);

void glutSolidCone(double base, double height, int slices, int stacks);
void glutWireCone(double base, double height, int slices, int stacks);

void glutSolidTorus(double inner_rad, double outer_rad, int nsides, int rings);
void glutWireTorus(double inner_rad, double outer_rad, int nsides, int rings);

void glutSolidDodecahedron(void);
void glutWireDodecahedron(void);

void glutSolidOctahedron(void);
void glutWireOctahedron(void);

void glutSolidTetrahedron(void);
void glutWireTetrahedron(void);

void glutSolidIcosahedron(void);
void glutWireIcosahedron(void);

void glutSolidTeapot(double size);
void glutWireTeapot(double size);


#ifdef __cplusplus
}
#endif

#endif	/* GLORY_GLUT_H_ */
